package com.dcrzl.gazgmh.module.mh.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.dcrzl.gazgmh.common.annotation.SysLog;
import com.dcrzl.gazgmh.common.entity.mh.MhMenu;
import com.dcrzl.gazgmh.common.utils.PageInfo;
import com.dcrzl.gazgmh.common.utils.Result;
import com.dcrzl.gazgmh.module.mh.service.MhMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 菜单管理
 *
 * @author dcrzl
 * @email 1728795786@qq.com
 * @date 2024-11-24 15:50:55
 */
@RestController
@RequestMapping("/mh/menu")
public class MhMenuController {
    @Autowired
    private MhMenuService mhMenuService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public Result<List<MhMenu>> list(MhMenu mhMenu) {
        return mhMenuService.selectList(mhMenu);
    }

    /**
     * 列表分页
     */
    @GetMapping("/page")
    public PageInfo<MhMenu> page(MhMenu mhMenu) {
        return mhMenuService.selectPage(mhMenu);
    }

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public Result<MhMenu> info(@PathVariable("id") Long id) {
        return mhMenuService.selectById(id);
    }


    /**
     * 保存
     */
    @SysLog("新增门户菜单")
    @PostMapping("/save")
    public Result<Integer> save(@RequestBody MhMenu mhMenu) {
        return mhMenuService.insert(mhMenu);
    }

    /**
     * 修改
     */
    @SysLog("修改门户菜单")
    @PutMapping("/update")
    public Result<Integer> update(@RequestBody MhMenu mhMenu) {
        return mhMenuService.updateById(mhMenu);
    }

    /**
     * 删除
     */
    @SysLog("删除门户菜单")
    @DeleteMapping("/delete")
    public Result<Integer> delete(@RequestBody Long[] ids) {
        return mhMenuService.deleteBatchIds(Arrays.asList(ids));
    }

}
